@extends('admin.layout.base')
@section('styles')
@endsection
@section('content')
    <div class="panel-content" id="app" v-cloak>
        <div class="panel-body panel-info">
            <el-form :model="form" ref="form" class="form" label-width="100px" >
                <div class="panel-header"> <div class="panel-title"> 基本信息 </div> </div>
                <div class="panel-main">
                    <el-form-item label="头像：" prop="avatar"><img :src="form.avatar" style="height: 60px;width: 60px;border-radius: 50%"/></el-form-item>
                    
                    <el-form-item label="身份：" prop="type">
                    	<el-input readonly v-model="form.type_name"></el-input>                    	
                    </el-form-item>
                    
                    <el-form-item v-else label="会员等级：" prop="reward_num">
                        <el-input clearable v-model="form.grade" readonly></el-input>
                    </el-form-item>
                    
                    <el-form-item label="真实姓名：" prop="username"><el-input readonly v-model="form.true_name"></el-input></el-form-item>
                    <el-form-item label="昵称：" prop="nickname"><el-input readonly v-model="form.nickname"></el-input></el-form-item>
                    <el-form-item label="手机号：" prop="mobile"><el-input readonly v-model="form.mobile"></el-input></el-form-item>
                    <el-form-item label="邮箱：" prop="email"><el-input readonly v-model="form.email"></el-input></el-form-item>
                    
                    <el-form-item label="状态：" prop="status">
                            <el-radio-group v-model="form.status">

                                <el-radio :label="2" border>正常</el-radio>
                                <el-radio :label="3" border>驳回</el-radio> 
                                <el-radio :label="4" border>拉黑</el-radio>                                    
                            </el-radio-group>
                    </el-form-item>
                    <el-form-item label="注册时间：" prop="created_at">
                        <el-input readonly v-model="form.created_at"></el-input>
                    </el-form-item>
                </div>
                
                <div class="panel-header"> <div class="panel-title"> 任务信息 </div> </div>
                <div class="panel-main">
                 	<el-form-item label="已提现金额：" prop="amount">
                        <el-input clearable v-model="form.amount" readonly></el-input>
                    </el-form-item>
                	<el-form-item label="现有余额：" prop="balance">
                        <el-input clearable v-model="form.balance" readonly></el-input>
                    </el-form-item>
                	<el-form-item v-if="form.type == 3" label="发布任务数：" prop="publish_num">
                        <el-input clearable v-model="form.publish_num" readonly></el-input>
                    </el-form-item>
                    <el-form-item v-else label="完成任务数：" prop="reward_num">
                        <el-input clearable v-model="form.reward_num" readonly></el-input>
                    </el-form-item>
                    
                     
               </div>
               	<div v-if="form.type == 2 || form.type == 3">
               	
                	<div class="panel-header"> <div class="panel-title"> 认证信息 </div> </div>
	                <div class="panel-main">
	                 	<el-form-item label="身份证号码" prop="IDcard">
	                        <el-input clearable v-model="form.IDcard" readonly></el-input>
	                    </el-form-item>
	                    <el-form-item label="身份证正面照" prop="positive_face">
	                		<img :src="form.positive_face" style="height: 100px;width: 150px;border-radius: 50%"/>
	                	</el-form-item>
	                	<el-form-item label="身份证反面照" prop="reverse_face">
	                		<img :src="form.reverse_face" style="height: 100px;width: 150px;border-radius: 50%"/>
	                	</el-form-item>
	               </div>
                	
                </div>
                <el-form-item style="padding-left: 150px;margin-top: 100px">
                    <el-button type="primary" @click="update()">确 定</el-button>
                    <el-button @click="back()" style="margin-left: 50px">返 回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
@endsection
@section('scripts')
    <script>
        let app = new Vue({
            el: '#app',
            data: function() {
                return {
                    form:{!! $info !!},
                }
            },
            created(){
                
                this.form._token = "{{csrf_token()}}";
            },
            methods: {
                //返回
                back(){
                    window.history.go(-1);
                },
                //更新
                update(){
                    let that = this;
                    this.$refs['form'].validate((valid) => {
                        if (valid) {
                            let that = this;
                            $.post("{{ route('admin.user.update') }}",this.form,function (res) {
                                if(res.code){
                                    that.$message.error(res.msg);
                                }else{
                                    that.$message({
                                        type: 'success',
                                        duration: '1000',
                                        message: res.msg,
                                        onClose:() =>{
                                            window.history.go(-1);
                                        }
                                    });
                                }
                            },'JSON');
                        }
                    });
                },
            }
        });
    </script>
@endsection
